<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of generateSymsL</title>
  <meta name="keywords" content="generateSymsL">
  <meta name="description" content="Generate the syms matrix L.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">source</a> &gt; generateSymsL.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for source&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>generateSymsL
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Generate the syms matrix L.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [ L ] = generateSymsL( n, m, hState, d ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">Generate the syms matrix L.

Generate syms matrix L, where n is the degree of matrix A and m is the
degree of A and m is the degree of the state vector x in homogeneous form.

Prototype: [L] = generateSymsL(n, m, hState, d)

Input:     n - Degree of A
           m - Degree of the state vector x in homogeneous form
           hState - Homogeneous state vector
           d - Dimension of homogeneous state vector hState

Output:    L - Syms matrix L</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="clearEquation.html" class="code" title="function [ clearedEquations ] = clearEquation( equations )">clearEquation</a>	Clean a given set of equations from every repeated equation.</li><li><a href="generateCoefficientEquationFromString.html" class="code" title="function [ theCoefficient ] = generateCoefficientEquationFromString( chr )">generateCoefficientEquationFromString</a>	Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="robLySearch.html" class="code" title="function [] = robLySearch( A, m )">robLySearch</a>	Calculate the stability of a system whit Homogeneous Lyapunov function.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">%Generate the syms matrix L.</span>
0002 <span class="comment">%</span>
0003 <span class="comment">%Generate syms matrix L, where n is the degree of matrix A and m is the</span>
0004 <span class="comment">%degree of A and m is the degree of the state vector x in homogeneous form.</span>
0005 <span class="comment">%</span>
0006 <span class="comment">%Prototype: [L] = generateSymsL(n, m, hState, d)</span>
0007 <span class="comment">%</span>
0008 <span class="comment">%Input:     n - Degree of A</span>
0009 <span class="comment">%           m - Degree of the state vector x in homogeneous form</span>
0010 <span class="comment">%           hState - Homogeneous state vector</span>
0011 <span class="comment">%           d - Dimension of homogeneous state vector hState</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%Output:    L - Syms matrix L</span>
0014 
0015 <a name="_sub0" href="#_subfunctions" class="code">function [ L ] = generateSymsL( n, m, hState, d )</a>
0016 
0017 syms x;
0018 <span class="keyword">for</span> i=1:n
0019     x(i) = [<span class="string">'x_'</span> int2str(i)];
0020 <span class="keyword">end</span>
0021 
0022 <span class="comment">%Row Vector hState without using ' because of conj() function</span>
0023 <span class="keyword">for</span> i=1:d
0024     hStateRow(i) = hState(i);
0025 <span class="keyword">end</span>
0026 
0027 <span class="comment">%Build the paramtric and symmetric matrix L.</span>
0028 <span class="comment">%If degree of matrix L is dxd, the number of parameters is defined as:</span>
0029 <span class="comment">%numOfParam = d + (d-1) + (d-2) + ... + 1</span>
0030 numOfParam = 0;
0031 <span class="keyword">for</span> i=1:d
0032     numOfParam = numOfParam + i;
0033 <span class="keyword">end</span>
0034 
0035 syms alfa;
0036 
0037 <span class="keyword">for</span> i=1:numOfParam
0038     alfa(i) = sdpvar(1);
0039 <span class="keyword">end</span>
0040 
0041 alfa_index = 1;
0042 <span class="keyword">for</span> i=1:d
0043     <span class="keyword">for</span> j=1:d
0044         <span class="keyword">if</span> j&gt;=i
0045             L(i,j)=alfa(alfa_index);
0046             alfa_index = alfa_index + 1;
0047         <span class="keyword">else</span>
0048             L(i,j)=L(j,i);
0049         <span class="keyword">end</span>
0050     <span class="keyword">end</span>
0051 <span class="keyword">end</span>
0052 
0053 system=hStateRow*L*hState;
0054 
0055 k=1;
0056 <span class="keyword">for</span> i=1:d
0057     <span class="keyword">for</span> j=i:d
0058         divisors(k) = hState(i)*hState(j);
0059         k=k+1;
0060     <span class="keyword">end</span>
0061 <span class="keyword">end</span>
0062 
0063 <span class="keyword">for</span> i=1:length(divisors)
0064     chr = char(expand(system/divisors(i)));
0065     equation{i} = <a href="generateCoefficientEquationFromString.html" class="code" title="function [ theCoefficient ] = generateCoefficientEquationFromString( chr )">generateCoefficientEquationFromString</a>(chr);
0066 <span class="keyword">end</span>
0067 
0068 equation = <a href="clearEquation.html" class="code" title="function [ clearedEquations ] = clearEquation( equations )">clearEquation</a>(equation);
0069 
0070 warning off
0071 <span class="keyword">for</span> i=1:length(equation)
0072     actualEquation = equation{i};
0073     found = false;
0074     j=1;
0075     <span class="keyword">while</span> found == false &amp;&amp; j &lt;= length(alfa)
0076         actualVariable = alfa(j);
0077         <span class="keyword">if</span> actualVariable == 0
0078             actualVariable = NaN;
0079         <span class="keyword">end</span>
0080         <span class="keyword">if</span> strfind(equation{i},char(actualVariable))
0081             alfa(j) = solve(actualEquation,actualVariable);
0082             found = true;
0083         <span class="keyword">else</span>
0084             j = j+1;
0085         <span class="keyword">end</span>
0086     <span class="keyword">end</span>
0087 <span class="keyword">end</span>
0088 warning on
0089 
0090 alfa_index = 1;
0091 <span class="keyword">for</span> i=1:d
0092     <span class="keyword">for</span> j=1:d
0093         <span class="keyword">if</span> j&gt;=i
0094             L(i,j)=strrep(char(alfa(alfa_index)), <span class="string">' '</span>, <span class="string">''</span>);
0095             alfa_index = alfa_index + 1;
0096         <span class="keyword">else</span>
0097             L(i,j)=L(j,i);
0098         <span class="keyword">end</span>
0099     <span class="keyword">end</span>
0100 <span class="keyword">end</span>
0101 
0102 <span class="keyword">return</span>;
0103 
0104 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Mon 12-Oct-2009 21:15:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>